<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
 <head>
  <meta http-equiv="content-type" content="text/html; charset=UTF-8">
  <title>Get file status</title>
<link media="all" rel="stylesheet" type="text/css" href="styles/03e73060321a0a848018724a6c83de7f-theme-base.css" />
<link media="all" rel="stylesheet" type="text/css" href="styles/03e73060321a0a848018724a6c83de7f-theme-medium.css" />

 </head>
 <body class="docs"><div class="navbar navbar-fixed-top">
  <div class="navbar-inner clearfix">
    <ul class="nav" style="width: 100%">
      <li style="float: left;"><a href="function.eio-fdatasync.html">« eio_fdatasync</a></li>
      <li style="float: right;"><a href="function.eio-fstatvfs.html">eio_fstatvfs »</a></li>
    </ul>
  </div>
</div>
<div id="breadcrumbs" class="clearfix">
  <ul class="breadcrumbs-container">
    <li><a href="index.html">PHP Manual</a></li>
    <li><a href="ref.eio.html">Eio 函数</a></li>
    <li>Get file status</li>
  </ul>
</div>
<div id="layout">
  <div id="layout-content"><div id="function.eio-fstat" class="refentry">
 <div class="refnamediv">
  <h1 class="refname">eio_fstat</h1>
   <p class="verinfo">(PECL eio &gt;= 0.0.1dev)</p><p class="refpurpose"><span class="refname">eio_fstat</span> &mdash; <span class="dc-title">Get file status</span></p>

 </div>

 <div class="refsect1 description" id="refsect1-function.eio-fstat-description">
  <h3 class="title">说明</h3>
  <div class="methodsynopsis dc-description">
   <span class="methodname"><strong>eio_fstat</strong></span>(<br>&nbsp;&nbsp;&nbsp;&nbsp;<span class="methodparam"><span class="type"><a href="language.types.declarations.html#language.types.declarations.mixed" class="type mixed">mixed</a></span> <code class="parameter">$fd</code></span>,<br>&nbsp;&nbsp;&nbsp;&nbsp;<span class="methodparam"><span class="type">int</span> <code class="parameter">$pri</code></span>,<br>&nbsp;&nbsp;&nbsp;&nbsp;<span class="methodparam"><span class="type"><a href="language.types.callable.html" class="type callable">callable</a></span> <code class="parameter">$callback</code></span>,<br>&nbsp;&nbsp;&nbsp;&nbsp;<span class="methodparam"><span class="type"><a href="language.types.declarations.html#language.types.declarations.mixed" class="type mixed">mixed</a></span> <code class="parameter">$data</code><span class="initializer"> = ?</span></span><br>): <span class="type">resource</span></div>

  <p class="para rdfs-comment">
   <span class="function"><strong>eio_fstat()</strong></span> returns file status information in
   <code class="parameter">result</code> argument of <code class="parameter">callback</code>
  </p>

 </div>


 <div class="refsect1 parameters" id="refsect1-function.eio-fstat-parameters">
  <h3 class="title">参数</h3>
  <dl>
   
    <dt>
<code class="parameter">fd</code></dt>

    <dd>

     <p class="para">
     Stream, Socket resource, or numeric file descriptor.
     </p>
    </dd>

   
   
    <dt>
<code class="parameter">pri</code></dt>

    <dd>

    <p class="para">请求的优先级：<strong><code>EIO_PRI_DEFAULT</code></strong>，<strong><code>EIO_PRI_MIN</code></strong>，<strong><code>EIO_PRI_MAX</code></strong> 或 <strong><code>null</code></strong>。如果是
<strong><code>null</code></strong>，<code class="parameter">pri</code> 将设为
<strong><code>EIO_PRI_DEFAULT</code></strong>。
</p>

    </dd>

   
   
    <dt>
<code class="parameter">callback</code></dt>

    <dd>

     <p class="para">
<code class="parameter">callback</code>
函数在请求完成时被调用。其应匹配一下原型：<div class="example-contents"><div class="phpcode"><code><span style="color: #000000">
void&nbsp;callback(mixed&nbsp;$data,&nbsp;int&nbsp;$result[,&nbsp;resource&nbsp;$req]);</span>
</code></div></div>

<dl>
 
  <dt>
<code class="parameter">data</code></dt>

  <dd>
<p class="para">传递给请求的用户数据。</p></dd>

 
 
  <dt>
<code class="parameter">result</code></dt>

  <dd>
<p class="para">针对请求的结果的值。通常是相应的系统调用返回的值。</p></dd>

 
 
  <dt>
<code class="parameter">req</code></dt>

  <dd>
<p class="para">可选的请求资源，可被 <span class="function"><a href="function.eio-get-last-error.html" class="function">eio_get_last_error()</a></span>
   之类的函数使用。</p></dd>

 
</dl>

</p>

    </dd>

   
   
    <dt>
<code class="parameter">data</code></dt>

    <dd>

     <p class="para">
     Arbitrary variable passed to <code class="parameter">callback</code>.
     </p>
    </dd>

   
  </dl>

 </div>


 <div class="refsect1 returnvalues" id="refsect1-function.eio-fstat-returnvalues">
  <h3 class="title">返回值</h3>
  <p class="para">
   <span class="function"><a href="function.eio-busy.html" class="function">eio_busy()</a></span> returns request resource on success, 或者在失败时返回 <strong><code>false</code></strong>.
  </p>
 </div>


 <div class="refsect1 examples" id="refsect1-function.eio-fstat-examples">
  <h3 class="title">范例</h3>
  <div class="example" id="example-3222">
   <p><strong>示例 #1 <span class="function"><a href="function.eio-lstat.html" class="function">eio_lstat()</a></span> example</strong></p>
   <div class="example-contents">
<div class="phpcode"><code><span style="color: #000000">
<span style="color: #0000BB">&lt;?php<br /></span><span style="color: #FF8000">//&nbsp;Create&nbsp;temporary&nbsp;file<br /></span><span style="color: #0000BB">$tmp_filename&nbsp;</span><span style="color: #007700">=&nbsp;</span><span style="color: #0000BB">dirname</span><span style="color: #007700">(</span><span style="color: #0000BB">__FILE__</span><span style="color: #007700">)&nbsp;.</span><span style="color: #DD0000">"/eio-file.tmp"</span><span style="color: #007700">;<br /></span><span style="color: #0000BB">touch</span><span style="color: #007700">(</span><span style="color: #0000BB">$tmp_filename</span><span style="color: #007700">);<br /><br /></span><span style="color: #FF8000">/*&nbsp;Is&nbsp;called&nbsp;when&nbsp;eio_fstat()&nbsp;done&nbsp;*/<br /></span><span style="color: #007700">function&nbsp;</span><span style="color: #0000BB">my_res_cb</span><span style="color: #007700">(</span><span style="color: #0000BB">$data</span><span style="color: #007700">,&nbsp;</span><span style="color: #0000BB">$result</span><span style="color: #007700">)&nbsp;{<br />&nbsp;</span><span style="color: #FF8000">//&nbsp;Should&nbsp;output&nbsp;array&nbsp;with&nbsp;stat&nbsp;info<br />&nbsp;</span><span style="color: #0000BB">var_dump</span><span style="color: #007700">(</span><span style="color: #0000BB">$result</span><span style="color: #007700">);<br /><br />&nbsp;if&nbsp;(</span><span style="color: #0000BB">$data</span><span style="color: #007700">[</span><span style="color: #DD0000">'fd'</span><span style="color: #007700">])&nbsp;{<br />&nbsp;&nbsp;</span><span style="color: #FF8000">//&nbsp;Close&nbsp;temporary&nbsp;file<br />&nbsp;&nbsp;</span><span style="color: #0000BB">eio_close</span><span style="color: #007700">(</span><span style="color: #0000BB">$data</span><span style="color: #007700">[</span><span style="color: #DD0000">'fd'</span><span style="color: #007700">]);<br />&nbsp;&nbsp;</span><span style="color: #0000BB">eio_event_loop</span><span style="color: #007700">();<br />&nbsp;}<br />&nbsp;</span><span style="color: #FF8000">//&nbsp;Remove&nbsp;temporary&nbsp;file<br />&nbsp;</span><span style="color: #007700">@</span><span style="color: #0000BB">unlink</span><span style="color: #007700">(</span><span style="color: #0000BB">$data</span><span style="color: #007700">[</span><span style="color: #DD0000">'file'</span><span style="color: #007700">]);<br />}<br /><br /></span><span style="color: #FF8000">/*&nbsp;Is&nbsp;called&nbsp;when&nbsp;eio_open()&nbsp;done&nbsp;*/<br /></span><span style="color: #007700">function&nbsp;</span><span style="color: #0000BB">my_open_cb</span><span style="color: #007700">(</span><span style="color: #0000BB">$data</span><span style="color: #007700">,&nbsp;</span><span style="color: #0000BB">$result</span><span style="color: #007700">)&nbsp;{<br />&nbsp;</span><span style="color: #FF8000">//&nbsp;Prepare&nbsp;data&nbsp;for&nbsp;callback<br />&nbsp;</span><span style="color: #0000BB">$d&nbsp;</span><span style="color: #007700">=&nbsp;array(<br />&nbsp;&nbsp;</span><span style="color: #DD0000">'fd'&nbsp;&nbsp;</span><span style="color: #007700">=&gt;&nbsp;</span><span style="color: #0000BB">$result</span><span style="color: #007700">,<br />&nbsp;&nbsp;</span><span style="color: #DD0000">'file'</span><span style="color: #007700">=&gt;&nbsp;</span><span style="color: #0000BB">$data<br />&nbsp;</span><span style="color: #007700">);<br />&nbsp;</span><span style="color: #FF8000">//&nbsp;Request&nbsp;stat&nbsp;info<br />&nbsp;</span><span style="color: #0000BB">eio_fstat</span><span style="color: #007700">(</span><span style="color: #0000BB">$result</span><span style="color: #007700">,&nbsp;</span><span style="color: #0000BB">EIO_PRI_DEFAULT</span><span style="color: #007700">,&nbsp;</span><span style="color: #DD0000">"my_res_cb"</span><span style="color: #007700">,&nbsp;</span><span style="color: #0000BB">$d</span><span style="color: #007700">);<br />&nbsp;</span><span style="color: #FF8000">//&nbsp;Process&nbsp;request(s)<br />&nbsp;</span><span style="color: #0000BB">eio_event_loop</span><span style="color: #007700">();<br />}<br /><br /></span><span style="color: #FF8000">//&nbsp;Open&nbsp;temporary&nbsp;file<br /></span><span style="color: #0000BB">eio_open</span><span style="color: #007700">(</span><span style="color: #0000BB">$tmp_filename</span><span style="color: #007700">,&nbsp;</span><span style="color: #0000BB">EIO_O_RDONLY</span><span style="color: #007700">,&nbsp;</span><span style="color: #0000BB">NULL</span><span style="color: #007700">,&nbsp;</span><span style="color: #0000BB">EIO_PRI_DEFAULT</span><span style="color: #007700">,<br />&nbsp;&nbsp;</span><span style="color: #DD0000">"my_open_cb"</span><span style="color: #007700">,&nbsp;</span><span style="color: #0000BB">$tmp_filename</span><span style="color: #007700">);<br /></span><span style="color: #0000BB">eio_event_loop</span><span style="color: #007700">();<br /></span><span style="color: #0000BB">?&gt;</span>
</span>
</code></div>
   </div>

   <div class="example-contents"><p>以上例程的输出类似于：</p></div>
   <div class="example-contents screen">
<div class="cdata"><pre>
array(12) {
 [&quot;st_dev&quot;]=&gt;
  int(2050)
  [&quot;st_ino&quot;]=&gt;
  int(2489159)
  [&quot;st_mode&quot;]=&gt;
  int(33188)
  [&quot;st_nlink&quot;]=&gt;
  int(1)
  [&quot;st_uid&quot;]=&gt;
  int(1000)
  [&quot;st_gid&quot;]=&gt;
  int(100)
  [&quot;st_rdev&quot;]=&gt;
  int(0)
  [&quot;st_blksize&quot;]=&gt;
  int(4096)
  [&quot;st_blocks&quot;]=&gt;
  int(0)
  [&quot;st_atime&quot;]=&gt;
  int(1318239506)
  [&quot;st_mtime&quot;]=&gt;
  int(1318239506)
  [&quot;st_ctime&quot;]=&gt;
  int(1318239506)
}
</pre></div>
   </div>
  </div>
 </div>



 <div class="refsect1 seealso" id="refsect1-function.eio-fstat-seealso">
  <h3 class="title">参见</h3>
  <ul class="simplelist">
   <li class="member"><span class="function"><a href="function.eio-lstat.html" class="function" rel="rdfs-seeAlso">eio_lstat()</a> - Get file status</span></li>
   <li class="member"><span class="function"><a href="function.eio-stat.html" class="function" rel="rdfs-seeAlso">eio_stat()</a> - Get file status</span></li>
  </ul>
 </div>


</div></div></div></body></html>